# `Predictor` classes provide an interface for efficient, repeated inference.

package(default_visibility = ["//third_party/tensroflow/contrib/predictor:__subpackages__"])

licenses(["notice"])  # Apache 2.0

exports_files(["LICENSE"])

load("//tensorflow:tensorflow.bzl", "py_test")

filegroup(
    name = "all_files",
    srcs = glob(
        ["**/*"],
        exclude = [
            "**/METADATA",
            "**/OWNERS",
        ],
    ),
    visibility = ["//tensorflow:__subpackages__"],
)

py_library(
    name = "predictor",
    srcs = [
        "__init__.py",
    ],
    srcs_version = "PY2AND3",
    visibility = ["//visibility:public"],
    deps = [
        ":predictor_factories",
    ],
)

py_library(
    name = "predictor_factories",
    srcs = [
        "predictor_factories.py",
    ],
    srcs_version = "PY2AND3",
    deps = [
        ":contrib_estimator_predictor",
        ":core_estimator_predictor",
        ":saved_model_predictor",
        "//tensorflow/contrib/learn",
    ],
)

py_library(
    name = "base_predictor",
    srcs = [
        "predictor.py",
    ],
    srcs_version = "PY2AND3",
)

py_library(
    name = "saved_model_predictor",
    srcs = [
        "saved_model_predictor.py",
    ],
    srcs_version = "PY2AND3",
    deps = [
        ":base_predictor",
        "//tensorflow/python/tools:saved_model_cli",
    ],
)

py_library(
    name = "core_estimator_predictor",
    srcs = [
        "core_estimator_predictor.py",
    ],
    srcs_version = "PY2AND3",
    deps = [
        ":base_predictor",
        "//tensorflow/contrib/learn",
    ],
)

py_library(
    name = "contrib_estimator_predictor",
    srcs = [
        "contrib_estimator_predictor.py",
    ],
    srcs_version = "PY2AND3",
    deps = [
        ":base_predictor",
        "//tensorflow/contrib/learn",
    ],
)

py_library(
    name = "testing_common",
    srcs = [
        "testing_common.py",
    ],
    srcs_version = "PY2AND3",
    tags = ["no_pip"],
    deps = [
    ],
)

# Transitive dependencies of this target will be included in the pip package.
py_library(
    name = "predictor_pip",
    visibility = ["//visibility:public"],
    deps = [
        ":contrib_estimator_predictor",
        ":core_estimator_predictor",
        ":saved_model_predictor",
    ],
)

py_test(
    name = "saved_model_predictor_test",
    srcs = [
        "saved_model_predictor_test.py",
    ],
    data = [":test_export_dir"],
    srcs_version = "PY2AND3",
    tags = ["no_pip"],
    deps = [
        ":saved_model_predictor",
        ":testing_common",
        "//tensorflow/python:client_testlib",
    ],
)

py_test(
    name = "core_estimator_predictor_test",
    srcs = [
        "core_estimator_predictor_test.py",
    ],
    srcs_version = "PY2AND3",
    tags = ["no_pip"],
    deps = [
        ":core_estimator_predictor",
        ":testing_common",
        "//tensorflow/python:client_testlib",
    ],
)

py_test(
    name = "contrib_estimator_predictor_test",
    srcs = [
        "contrib_estimator_predictor_test.py",
    ],
    srcs_version = "PY2AND3",
    tags = ["no_pip"],
    deps = [
        ":contrib_estimator_predictor",
        ":testing_common",
        "//tensorflow/python:client_testlib",
        "//third_party/py/numpy",
    ],
)

filegroup(
    name = "test_export_dir",
    srcs = glob(["test_export_dir/**/*"]),
    tags = ["nopip"],
)
